import os


class DirMonitor(object):
    def __init__(self, monitor_dir):
        super(DirMonitor, self).__init__()
        self.dir = monitor_dir + "/"
        self.old_files = []

    def watch_changes(self):
        new_files = os.listdir(self.dir)
        new_files.sort(key=lambda x: int(x[:-4]))
        added = [self.dir + f for f in new_files if not f in self.old_files]
        self.old_files = new_files
        return added


if __name__ == '__main__':
    dm = DirMonitor('/home')
    dm.watch_changes()
